import 'package:flutter/material.dart';
import 'package:s_mankey/config/resource_mananger.dart';
import 'package:s_mankey/config/router_config.dart';
import 'package:s_mankey/provider/provider_widget.dart';
import 'package:s_mankey/ui/widget/loading_widget.dart';
import 'package:s_mankey/view_model/my_page_vmodel.dart';

class CheckInfo extends StatelessWidget {
  CheckInfo({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ProviderWidget<MyPageFirstDetailVModel>(
      model: MyPageFirstDetailVModel(),
      onModelReady: (model) => model.initData(),
      builder: (context, model, child) {
        if(model.isBusy)return LoadingWidget();
        if(model.isError)return Text('出错了');
        if(model.isEmpty)return Text('没有数据');
        Map<String, dynamic> datas = model.datas['member'];
        return
          Scaffold(
          backgroundColor: Colors.white,
          appBar: AppBar(
            elevation: 0,
          ),
          body: ListView(
            children: [
              Padding(
                padding: const EdgeInsets.only(top: 20),
                child: Column(
                  children: <Widget>[
                    ///用户信息
                    Stack(
                      children: <Widget>[
                        Container(
                          margin: EdgeInsets.fromLTRB(0, 40, 0, 30),
                          padding: EdgeInsets.fromLTRB(0, 50, 0, 20),
                          decoration: BoxDecoration(
                              color: Colors.white,
                              boxShadow: [
                                BoxShadow(
                                    color: Colors.grey[100],
                                    offset: Offset(0, -4),
                                    blurRadius: 2,
                                    spreadRadius: 1)
                              ],
                              borderRadius: BorderRadius.only(
                                  topLeft: Radius.circular(50),
                                  topRight: Radius.circular(50))),
                          child: Column(
                            children: <Widget>[
                              Padding(
                                padding: const EdgeInsets.only(top: 15),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: <Widget>[
                                    Text(datas['username']),
                                    model.sexIcon,
                                  ],
                                ),
                              ),
                              Padding(
                                padding: const EdgeInsets.only(top: 10),
                                child: Text.rich(TextSpan(children: [
                                  TextSpan(
                                    text: '签名：',
                                  ),
                                  TextSpan(
                                      text: datas['description'],
                                      style:
                                          TextStyle(color: Color(0xffb7b7b7))),
                                ])),
                              ),
                              Padding(
                                padding: const EdgeInsets.only(top: 10),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: <Widget>[
                                    Row(
                                      children: <Widget>[
                                        Text('关注'),
                                        Text((datas['favorites_count'])
                                            .toString()),
                                      ],
                                    ),
                                    Container(
                                      width: 120,
                                    ),
                                    Row(
                                      children: <Widget>[
                                        Text('粉丝'),
                                        Text((datas['fans_count']).toString()),
                                      ],
                                    )
                                  ],
                                ),
                              )
                            ],
                          ),
                        ),
                        Center(
                          child: Container(
                            width: 80,
                            height: 80,
                            decoration: BoxDecoration(
                                image: DecorationImage(
                                    image: NetworkImage(datas['header_img']),
                                    fit: BoxFit.fill),
                                border: Border.all(
                                    color: Color(0xfff9f9fa), width: 4),
                                borderRadius:
                                    BorderRadius.all(Radius.circular(40.0))),
                          ),
                        ),
                      ],
                    ),
                    Container(
                      color: Color(0xfff8f8f8),
                      height: 15,
                    ),

                    /// 基本信息
                    Container(
                      margin: EdgeInsets.fromLTRB(10, 0, 10, 0),
                      decoration: BoxDecoration(
                          color: Colors.white,
                          border: Border(
                              bottom:
                                  BorderSide(color: AppColor.dividerColor))),
                      height: 55,
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          GestureDetector(
                            behavior: HitTestBehavior.opaque,
                            onTap: () {
                              Navigator.pushNamed(context, RouterName.editInfo);
                            },
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: <Widget>[
                                Text(
                                  '基本信息',
                                  style:
                                      TextStyle(fontSize: AppFontSize.Size20),
                                ),
                                IconFonts.rightIcon,
                              ],
                            ),
                          ),
                        ],
                      ),
                    ),

                    Container(
                      margin: EdgeInsets.fromLTRB(10, 0, 10, 0),
                      decoration: BoxDecoration(
                          color: Colors.white,
                          border: Border(
                              bottom:
                                  BorderSide(color: AppColor.dividerColor))),
                      height: 55,
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Row(
                            children: <Widget>[
                              Text(
                                '信息',
                                style: TextStyle(
                                    fontSize: AppFontSize.Size16,
                                    color: Color(0xff959595)),
                              ),
                              Container(
                                width: 250,
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceAround,
                                  children: List.generate(
                                      model.baseInfo.length,
                                      (index) => Text(
                                            model.baseInfo[index],
                                            style: TextStyle(
                                                fontSize: AppFontSize.Size16,
                                                fontWeight: FontWeight.w500),
                                          )),
                                ),
                              ),
                            ],
                          ),
                        ],
                      ),
                    ),

                    //课程信息
                    Container(
                      margin: EdgeInsets.fromLTRB(10, 0, 10, 0),
                      decoration: BoxDecoration(
                          color: Colors.white,
                          border: Border(
                              bottom:
                                  BorderSide(color: AppColor.dividerColor))),
                      height: 55,
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Text(
                                '课程信息',
                                style: TextStyle(fontSize: AppFontSize.Size20),
                              ),
                            ],
                          ),
                        ],
                      ),
                    ),

                    Container(
                      padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                      color: Colors.white,
                      child: Column(
                        children: List.generate(
                          3,
                          (index) => Container(
                            padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                            decoration: BoxDecoration(
                                border: Border(
                                    bottom: BorderSide(
                                        color: AppColor.dividerColor))),
                            height: 55,
                            child: Row(
                              children: <Widget>[
                                Text('誓约',
                                    style: TextStyle(
                                        fontSize: AppFontSize.Size16,
                                        color: Color(0xff959595))),
                                Padding(
                                  padding: EdgeInsets.only(left: 30),
                                  child: Text(
                                    '暂无信息',
                                    style: TextStyle(
                                        fontSize: AppFontSize.Size16,
                                        fontWeight: FontWeight.w500),
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        );
      },
    );
  }
}
